home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 27
/
Commodore_Free_Issue_27_2009_Commodore_Computer_Club.d64
/
big screen vic
< prev
next >
Wrap
Text File
|
2023-02-26
|
9KB
|
335 lines
..
Graphics & Bigger Screen
in BASIC on expanded VIC20
(This article has previously been
posted on the VIC20 forum 'Denial':
http://sleepingelephant.com/
denial/index.html
but this version has a few updates...)
First, (as everyone probably knows),
whth expansion memory (ram in block 1)
then both the basic memory & screen
are moved to other positions in memory
The screen now starts at: 4096 (7680
on unexpanded).
The colours for the screen start at
37888 (38400 on unex.) BASIC memory
starts at 18*256+1=4609 (4097 on unex)
If you are going to use expansion ram
& want to use your own graphics (or a
bigger screen), then you need to move
BASIC memory. The reason for this is
that the VIC chip only can access
internal memory (not expansion memory)
And by default, it only has enough
memory for the default screen before
BASIC memory starts. It's made this
way so that all of the memory can be
used for BASIC programs by default.
So you need to alter the start address
of the BASIC memory & move it forward
in memory to make room for things that
need access to the VIC chip. So that
these things can be put in internal
memory.
(It is however possible to put
graphics data in the internal tape
buffer if you think it's enough with
only 38 characters & a normal sized
screen. Then you don't need to move
the BASIC memory at all. More about
this later.)
Moving the BASIC memory
If you for example do this:
POKE44,32:POKE32*256,0:NEW
Then BASIC memory will start at the
expansion ram (8192) & leave the whole
graphics memory free for your own
graphics, a bigger screen, etc...
(32*256 = 8192). You might not need to
move it that far though. For example
on my Tribbles game:
http://user.tninet.se/{$de}pug510w/
datormuseum/tribbles.html
I have it at 28*256 I think
(POKE 44,28:POKE28*256,0:NEW)
REMEMBER - Always load BASIC programs
with just ,8 !!! If you load it ,8,1
then it will be loaded to the same
memory position from where it was
saved, & that is not very good when
you have moved BASIC memory.
A bigger screen
Now when you have moved your memory,
you can use some internal memory for a
bigger screen. (Mostly usable on PAL
where quite much of the display is
unused.) You alter the screen size &
positions with the following VIC
registers:
36864 bits 0-6: screen horiz. centre
36865: screen vert. centre
36866 bits 0-6: number of columns
36867 bits 1-6: number of rows
In BASIC, to set:
screen x position: POKE 36864,x
screen y position: POKE 36865,y
screen width: POKE 36866,
(PEEK(36866)AND128)+w
screen height: POKE 36867,
(PEEK(36867)AND129)+h*2
For an example in BASIC (& for trying
different settings out), download my
"overscan" program.
http://user.tninet.se/{$de}pug510w/
datormuseum/oldvic20page.html#overscan
When you have opened a bigger screen
with a different column size than the
default, then the lines will behave
strangely, but don't worry, this is
normal! The system screen still is
22x23 regardless of how big your
screen is, & this is why the screen
seems to behave strangely. If you
don't like this, then keep the
original width & only make the screen
taller. It's here much of the unused
space is anyway (on PAL). You can't
use print commands to put stuff in the
extra space. So the only way (in pure
BASIC) is to POKE. The screen just
continues beyond where the default
screen ends at 4602, so pokeing values
greater than that changes the contents
of the extra space on the screen. It
works exactly as pokeing on the normal
screen, but you just have a bigger
space now. Another way is to use my
"Extra Screen" program,
http://user.tninet.se/{$de}pug510w/
datormuseum/extrascreen.html
then you can use normal print commands
(almost). (You are allowed to include
the machine language part in your
programs)
An example using "Extra screen":
10 PRINT "{SHIFT-+}CLR{SHIFT--}This text will be put"
20 PRINT "in the extra space below"
30 PRINT "the 'normal' screen."
40 SYS 5352
50 PRINT "{SHIFT-+}CLR{SHIFT--}And this will be on
the"
60 PRINT "very top of the whole
screen."
SYS 5352 just copies the "normal"
screen to below the "normal" screen in
a jiffy. In other words, you don't
need to start the whole "EXTRA SCREEN"
program, just use this little routine
to copy the screen. I did this in my
Mega Omega game.
http://user.tninet.se/{$de}pug510w/
datormuseum/oldvic20page.html#omega
Graphics
This is pretty straight forward. You
reserve memory the way described above
& then find a suitable place in memory
(after the space used for the bigger
screen). The register to use is:
36869 Bits 0-3
In BASIC: POKE 36869,
(PEEK(36869)AND240)+a
The addresses 'a' you can use is
13 for 5120
14 for 6144
15 for 7168
8 for 824 (chars 103-127) &
664 (chars 83-95) (Thanks Mobsie!)
0-3 for the character ROM
So for example, POKE 36869,
(PEEK(36869)AND240)+14
will use the graphics data at memory
address 6144 & forward.
The easiest way to do graphics is to
use some program to draw directly into
the memory & then save the memory out
as a file (for example with a machine
language monitor). I usually use The
Final Cartridge's ML monitor on the
C64 to input & save the graphics. Then
when you are to use it, you just load
,8,1 & it will load in the right place
The tape buffer - Selecting 8 as 'a'
above makes it possible to put
graphics in the internal tape buffer.
For this you don't need to move the
BASIC memory or anything. And it
should work on both expanded & unex-
panded VICs!!! Also it seems to be the
only possible position if you intend
to compile your program with the
Austro Compiler.
ftp://ftp.zimmers.net/pub/cbm/
vic20/utilities/8k/Austro-
Compiler.prg>Austro Compiler
Here is a demo of how to use this
position: Winter simulator.
http://user.tninet.se/{$de}pug510w/
datormuseum/snow.html
Working/& Saving
When working on a project, it's easier
to first load any graphics & ML
files,8,1, then move BASIC memory as
described earlier & last load the
BASIC ,8. Then just save the BASIC
program ,8 as you progress with better
& better versions.... But when you are
ready & want to turn it into something
that others easily can load on their
VIC... Then there are two approaches.
1. The multiple file approach
2. Single file approach
The multiple file thing is simply that
you make a loader that moves memory &
loads all the files. It can be a
little tricky as the NEW command is
used to move the BASIC memory... A tip
if you like to use this approach is to
use the keyboard buffer that starts at
position 631. Position 198 holds the
number of letters in the buffer. So by
doing this: POKE631,131:POKE198,1 You
put a "LOAD/RUN" keypress in the
keyboard buffer. And if you before
that print something like LOAD
"PROGRAM",8{SHIFT-+}up{SHIFT--}{SHIFT-+}up{SHIFT--}{SHIFT-+}up{SHIFT--} on the screen,
then you can make it load a program
even after the new command. Take a
look at the first file of my "VIC
EXTRA SCREEN" as an example.
The Single file thing is a lot nicer,
& it also makes your game work on both
disk & tape. It involves having 2
BASIC programs as well as any graphics
& ML parts in memory at the same time
& then saving the whole thing. The
main BASIC program at your new moved
BASIC position plus a little starting
program at the original BASIC position
that moves memory & runs the main
program.
To run a BASIC program that is some-
where else in memory & not in current
BASIC memory, you have to set these
pointers first:
43-44 Start of Basic
45-46 Start of Variables First byte
after program
47-48 Start of Arrays First byte
after program
49-50 End of Arrays First byte
after program
51-52 String storage End of
memory+1
Let's say we have the whole memory set
up like this:
-Small Basic start
-Room for bigger screen
-Machine Language
-Graphics Data
-Main Basic program
When a program is loaded, the pointers
45,46 etc. are automatically set to
behind the loaded program, & because I
have the BASIC program last in the
resulting file, those pointers are set
by themselves when the file is loaded.
Because of this, I only have to change
the start pointer.
So, if you have the BASIC starting at
8192, you only have to do the
following...
(RESET)
10 POKE 44,32:RUN
(make the small BASIC start)
LOAD "gfx & machine language part",8,1
(loads into the graphics mem)
POKE 44,32: POKE 32*256,0: NEW
(move BASIC to 8192)
LOAD "BASIC part",8
(load main BASIC part)
POKE 44,18
(move back the beginning of BASIC to
default)
SAVE "whole program",8
(And everything saves as one big file)
Very nice as you don't even have to
bother to look what the ending address
is...
Good luck!
Anders Persson
http://listen.to/boray
Commodore Free -
Would like thank Anders Persson for
the reprint of the article.
..end..